package t3;

import java.util.Calendar;
import java.util.List;

import t3bean.CarBean;
import t3bean.ParkingLotBean;
import t3bean.ParkingSpaceBean;

/**
 * 停车操作
 *
 */
public class ParkingCar {
	public ParkingLotBean parkingCar(ParkingLotBean pl, CarBean car) {
		if (car.getLicensePlate() != null && car.getHeight() < 3) {
			List<ParkingSpaceBean> pSList = pl.getpSList();
			for (ParkingSpaceBean pS : pSList) {
				if (pS.getIsParking() == 0) {
					pS.setIsParking(1);
					// 获取时间
					Calendar cal = Calendar.getInstance();
					long datelong = cal.getTimeInMillis();
					pS.setParkingTime(datelong);
					pS.setCar(car);
					System.out.println("停车成功");
					System.out.println();
					break;
				}
			}
		} else {
			System.out.println("高度太高！停车失败！");
		}
		return pl;
	}
}
